import React, { Component } from 'react'

export default class Child2 extends Component {
  constructor (props) {
    super()
    // super(props)

    // 构造器中，要通过形参，获取
    console.log('---child2 props---', props)
  }

  clickMe = () => {
    // react也是遵循单向数据流的
    // this.props.isMan = false

    this.props.callback(false)
  }

  // 构造器外面，就通过this.props获取
  render () {
    return (
      <div>
        Child2
        <p>{this.props.isMan ? '男士' : '女士'}</p>
        <p>
          province is {this.props.address.province} city is{' '}
          {this.props.address.city}
        </p>
        <p>
          <button onClick={this.clickMe}>click</button>
        </p>
      </div>
    )
  }
}
